﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Presenters.Add_Presenters;
using Views.Status_Views;
using Interfaces.Add_Interfaces;

namespace Views.Add_Views
{
    public partial class DocumentAddView : Form, IDocumentAddView
    {
        private DocumentAddPresenter presenter = null;

        public DocumentAddView()
        {
            InitializeComponent();
            presenter = new DocumentAddPresenter(this);
        }

        public event EventHandler<EventArgs> Save;
        public event EventHandler<EventArgs> Browser;

        string IDocumentAddView.binder
        {
            get
            {
                return binder.Text;
            }
            set
            {
                binder.Text = value as string;
            }
        }

        string IDocumentAddView.nameDocument
        {
            get
            {
                return nameDocument.Text;
            }
            set
            {
                nameDocument.Text = value as string;
            }
        }

        string IDocumentAddView.pathDocument
        {
            get
            {
                return pathDocument.Text;
            }
            set
            {
                pathDocument.Text = value as string;
            }
        }

        private void Savebt_Click(object sender, EventArgs e)
        {
            if (Save != null)
                Save(this, EventArgs.Empty);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (Browser != null)
                Browser(this, EventArgs.Empty);
        }

        void Interfaces.Inherited_Interfaces.ICloseable.Close()
        {
            this.Close();
        }

        void Interfaces.Inherited_Interfaces.ISuccess.ShowSuccess()
        {
            presenter.ShowSuccess(new SuccessView());
        }

        void Interfaces.Inherited_Interfaces.IError.ShowError()
        {
            presenter.ShowError(new ErrorView());
        }

        T Interfaces.Inherited_Interfaces.IView.ReturnView<T>()
        {
            return (T)((object)this);
        }
    }
}
